﻿<UserControl x:Class="Big3.Hitbase.MainControls.WishListUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:dd="clr-namespace:Big3.Hitbase.Controls.DragDrop;assembly=Controls"
             xmlns:sr="clr-namespace:Big3.Hitbase.SharedResources;assembly=Big3.Hitbase.SharedResources"
             mc:Ignorable="d" Name="WishlistUserControl"
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <Style TargetType="ListBoxItem" x:Key="MyItemContainerStyle">
            <Setter Property="Margin" Value="0"/>
            <Setter Property="Padding" Value="0"/>
            <Style.Resources>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="AliceBlue"></SolidColorBrush>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black"></SolidColorBrush>
            </Style.Resources>
        </Style>

        <Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" >


        </Style>

        <DataTemplate x:Key="WishlistItem">
            <DockPanel>
                <Image DockPanel.Dock="Left" Source="{Binding ImageFilename}" Margin="0,0,4,0" Stretch="Uniform" Width="40" Height="40">
                    <Image.Effect>
                        <DropShadowEffect Color="Gray" ShadowDepth="2" />
                    </Image.Effect>
                </Image>
                <StackPanel Orientation="Vertical">
                    <TextBlock Text="{Binding Title}" TextTrimming="CharacterEllipsis" ></TextBlock>
                    <TextBlock Foreground="Gray" Text="{Binding Artist}" TextTrimming="CharacterEllipsis" ></TextBlock>
                    <TextBlock Foreground="Gray" Text="{Binding From}" TextTrimming="CharacterEllipsis" ></TextBlock>
                </StackPanel>
            </DockPanel>
        </DataTemplate>
    </UserControl.Resources>
    <UserControl.CommandBindings>
        <CommandBinding Command="sr:HitbaseCommands.SaveWishlist" Executed="CommandBindingSaveWishlist_Executed" />
        <CommandBinding Command="sr:HitbaseCommands.PrintWishlist" Executed="CommandBindingPrintWishlist_Executed" />
    </UserControl.CommandBindings>
    <DockPanel>
        <Grid DockPanel.Dock="Top">
            <Grid.Background>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <GradientStopCollection>
                        <GradientStop Offset="0" Color="#8FFFFFFF" />
                        <GradientStop Offset="1" Color="#3FFFFFFF" />
                    </GradientStopCollection>
                </LinearGradientBrush>
            </Grid.Background>
            <TextBlock Text="{sr:Loc Wishlist}" Margin="2" />

            <Button Margin="0,0,50,0" ToolTip="{sr:Loc SaveWishlist}" Command="sr:HitbaseCommands.SaveWishlist" HorizontalAlignment="Right" VerticalAlignment="Center">
                <Image Source="/Big3.Hitbase.SharedResources;component/Images/Save.png" Width="16" Height="16" />
            </Button>
            <Button Margin="0,0,25,0" ToolTip="{sr:Loc PrintWishlist}" Command="sr:HitbaseCommands.PrintWishlist" HorizontalAlignment="Right" VerticalAlignment="Center">
                <Image Source="/Big3.Hitbase.SharedResources;component/Images/Print.png" Width="16" Height="16" />
            </Button>

            <Button Margin="0,0,2,0" Background="Transparent" HorizontalAlignment="Right" VerticalAlignment="Center" 
                    Name="CloseButton" Click="CloseButton_Click" Style="{StaticResource ButtonStyleCloseButton}" 
                    ToolTip="{sr:Loc Close}" />
        </Grid>

        <ListBox AllowDrop="True"  ItemTemplate="{StaticResource WishlistItem}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
                 HorizontalContentAlignment="Stretch" Name="listBoxWishlist" BorderThickness="0" ItemContainerStyle="{StaticResource MyItemContainerStyle}" 
                 Background="Transparent" ItemsSource="{Binding ElementName=WishlistUserControl, Path=Wishlist}" 
                 MouseDoubleClick="listBoxWishlist_MouseDoubleClick"
                 dd:DragDrop.IsDragSource="true" dd:DragDrop.IsDropTarget="true" 
                 dd:DragDrop.DragAdornerTemplate="{StaticResource WishlistItem}"
                 dd:DragDrop.DropHandler="{Binding}">
            <ListBox.CommandBindings>
                <CommandBinding Command="sr:HitbaseCommands.DeleteWishlistItem" Executed="CommandBindingDeleteWishlistItem_Executed" CanExecute="CommandBindingDeleteWishlistItem_CanExecute" />
            </ListBox.CommandBindings>
            <ListBox.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Aus Wunschliste entfernen" Command="sr:HitbaseCommands.DeleteWishlistItem">
                        <MenuItem.Icon>
                            <Image Source="/Big3.Hitbase.SharedResources;component/Images/Delete.png" />
                        </MenuItem.Icon>
                    </MenuItem>
                </ContextMenu>
            </ListBox.ContextMenu>
        </ListBox>
    </DockPanel>
</UserControl>
